import { channels } from "@/api/index.js";

export default {
  namespaced: true,
  state: {
    list: [],
    current: "",
  },
  mutations: {
    SETLIST(s, val) {
      s.list = val;
    },
    SETCURRENT(s, id) {
      s.current = id;
    },
  },
  getters: {},
  actions: {
    async getTypeList({ commit, dispatch }, id) {
      const {
        data: { data },
      } = await channels();
      console.log(data);
      commit("SETLIST", data.channels);
      commit("SETCURRENT", data.channels[0].id);
      // 获取到频道分类内标后在能拿到id ，再调用其他模块的actions方法
      dispatch("list/getArtList", data.channels[0].id, { root: true });
    },
  },
};
